<template>
  <select class="form-select" v-model.number="paymentId0" :id="id">
    <option value="0">请选择</option>
    <option :value="info.id" v-for="info in showingPayments" :key="info.id">
      {{ info.name }}
    </option>
  </select>
</template>


<script>
import { searchPaymentMethods } from "@/api/basic-data.js";

export default {
  props: {
    id: "",
    paymentId: {
      type: Number,
      default: 0,
    },
  },
  data() {
    return {
      payments: [],
      paymentId0: 0,
    };
  },
  watch: {
    paymentId: function (newVal, oldVal) {
      this.paymentId0 = this.paymentId;
    },
    paymentId0: function (newVal, oldVal) {
      this.$emit("update:paymentId", newVal);
    },
  },
  computed: {
    showingPayments: function () {
      return this.payments.filter(function (info) {
        return true;
      });
    },
  },
  mounted: function () {
    this.searchPayments();
  },
  methods: {
    searchPayments: function () {
      const params = {
        "sc.pageNo": 1,
        "sc.pageSize": 1000,
        "sc.status": 1,
      };

      searchPaymentMethods(params, (jsonResult) => {
        this.payments = jsonResult.dataList;
      });
    },
  },
};
</script>
